package o;

import android.graphics.Bitmap;
import android.graphics.Color;
import android.text.TextUtils;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.List;
import o.dky.d;
import o.eru.b;

public abstract class erq {
    public static int ˎ(Bitmap bitmap) {
        int color = ContentManager.getInstant().getContext().getResources().getColor(d.ˋˊ);
        if (bitmap == null) {
            return color;
        }
        Collection ˎ = eru.ˏ(bitmap).ˎ();
        if (ˎ.isEmpty()) {
            return color;
        }
        List arrayList = new ArrayList(ˎ);
        Collections.sort(arrayList, new erv());
        if (arrayList.isEmpty()) {
            return color;
        }
        return ((b) arrayList.get(0)).ˋ();
    }

    public static boolean ˏ(int i) {
        int[] iArr = new int[]{(16711680 & i) >> 16, (65280 & i) >> 8, i & 255};
        if (((int) ((((double) iArr[2]) * 0.114d) + ((((double) iArr[0]) * 0.299d) + (((double) iArr[1]) * 0.587d)))) < 192) {
            return true;
        }
        return false;
    }

    public static int ˊ(int i, float f) {
        if (f == 1.0f) {
            return i;
        }
        return Color.argb((int) (((float) Color.alpha(i)) * f), Color.red(i), Color.green(i), Color.blue(i));
    }

    public static int ॱ(String str, Bitmap bitmap) {
        if (TextUtils.isEmpty(str)) {
            return ˎ(bitmap);
        }
        try {
            return Color.parseColor(str);
        } catch (IllegalArgumentException e) {
            return ˎ(bitmap);
        }
    }
}
